home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
101-125
/
scopedisk120
/
iconj
/
iconj.doc
< prev
next >
Wrap
Text File
|
1995-03-19
|
30KB
|
606 lines
©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©
IconJ and AtatJ, version 1.0, © 1990 by Rich Franzen
Programs and/or source code may be freely disseminated so long as
only a small (if any) charge is made to cover costs. The executable
files are not to be altered; the source code may be modified so long
as it is clearly labeled as to the modification's source and purpose.
The IconJ program may be included with commercial software packages
so long as no additional charge is made for its inclusion and I
(Rich Franzen) am given credit as its author. (I would appreciate
notification if IconJ is so included, but this is not required. An
offer of a discount to a commercial package which includes IconJ
would also be appreciated, but this is certainly not required
either.) I reserve the right to limit the distribution of any later
version of IconJ or AtatJ. Attempts by third parties, however, to
limit/redefine this distribution are null, void, hubristic, and
laughable.
This software is provided "as is". Although every effort has been
made to have it function in accord with this document, the author
shall not be responsible for problems users may experience with it.
©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©
INTRODUCTION TO IconJ AND AtatJ
IconJ is a Workbench (WB, ® Commodore-Amiga) utility that allows
execution of scripts (aka "batch files") by clicking an icon assigned to
that script. Workbench already provides a pretty-good utility, called
IconX, for this purpose. Sometimes, however, "pretty-good" is not good
enough. IconX has the following limitations:
1) its output cannot be sent to files
2) it does not provide full support for conditional execution
3) it does not allow interaction by the user from the keyboard
4) it will not execute ARexx (® William S. Hawes) scripts
These limitations can all be solved in an indirect manner. Namely, the
IconX script can execute a second script, and that script would provide
full flexibility.
The indirect solution is not ideal, however. It calls for at least
three files to do one thing: the main script, the called script, and the
icon file associated with the main script. These scripts are often
involved in setting up an environment for running a machine-language
program, which would be a fourth file. AmigaDOS ® diskettes and hard
drives are not really efficient with their directory structures to begin
with, and all these extra files add to that problem. This is all made
worse by the fact that a fundamental feature of Workbench is lost when the
third or fourth file is added to the set--it cannot be "dragged" somewhere
else without losing part of itself!
IconJ and AtatJ Manual Page 1
BEYOND PRETTY-GOOD
So, IconJ was born. I had several goals when writing it:
1) to be 100% compatibile with IconX
2) to overcome the limitations of IconX
3) to allow a script to function identically from Workbench
as it would from a cli (command line interface)
4) (personal) to begin to learn how to program the Amiga
Additionally, I added increased functionality by allowing the script to be
located in a file anywhere in the Amiga system, even in the icon file
itself! The "J" at the end of IconJ represents the ability to "join" a
script onto the end of the icon file. (It could also mean that the program
is written in JForth (® Delta Research), but this may be just a happy
coincidence.) Each Workbench icon represents two files, namely the actual
file whose name appears below the icon and the file which contains the
iconic picture displayed on the screen. For the remainder of this
document, I will call the icon file the ".info" file and the file which is
not the ".info" file the "~info" file ("dot-info" and "not-info"--hey, I'm
a programmer; we've got a license to name things like this!).
The script is not required to be part of the .info file (which would
make IconJ incompatible with IconX); indeed, most of the time you will be
better off with the script separate, usually as the ~info brother.
Sometimes the script will better belong in a different directory than that
of the icon. For example, if the "S:" directory is in your cli search path,
you may want a script there but still desire the ability to activate it
from Workbench.
A case when it is desirable to have the script attached to the icon is
when there is a machine language program which requires set-up before it is
activated. For example, I normally use BlitzDisk (® Microsmiths, Inc) to
speed up my floppy access. I also occasionally use a program called B.A.D.
(® M.V. Micro) which restructures a diskette to be more efficient.
BlitzDisk and B.A.D. don't like each other; if B.A.D. is run with BlitzDisk
active, my Amiga will crash. The solution was to have a script for B.A.D.
that shut off BlitzDisk, executed B.A.D., and turned BlitzDisk back on when
B.A.D. finished. This works fine, even with IconX, except that I can no
longer drag B.A.D. from drawer to drawer--I only move the icon and the
script; B.A.D. itself stays wherever it was. With IconJ, that short little
script can be part of the icon for B.A.D., and the ability to drag the file
around is restored.
A short script (the example above is three lines) can easily be added
to the icon with the "Info" tool available from the Workbench menu. The
.info file must be type "project", which means that the icon actually
activates two files when double-clicked. The first is the one in the
"default tool" box of the Info window, and the second, which is acted on by
the first, is the file associated with the icon (in our case, a script).
IconJ and AtatJ Manual Page 2
To get the project icon to run an attached script, "c:IconJ" is written in
the "default tool" box. Then the "tool types" box is manipulated to add
several lines at the end of any existing tool types. To tell IconJ that
the script is joined with the icon, a "SCRIPT=" tool type must be written,
saying something like "SCRIPT=.info". Then IconJ will know that each tool
type which follows the SCRIPT= tool is actually a line of the script it is
to execute.
What follows is a very simplified Info screen for a project icon
containing an internal script. In reality, only one tool type is visible
at a time (accessed via the up/down gadgets), but this example pretends you
can see them all at once. Note that IconJ requires no tool types at all;
everything has a default. Also, standard tool types that IconJ does not
understand, such as "FILETYPE=TEXT", can be included if desired. The only
restriction is that if "SCRIPT=.info" is specified (perhaps with one or
more switches), it must be the last of the formal tool types. All lines
that follow it will be treated as part of your script.
COMMENT B.A.D. (Blitz-A-Disk), © 1988 MV Micro, v3.11
DEFAULT TOOL c:IconJ
TOOL TYPE ; DELAY=150 [ADD] [DEL]
WINDOW=100/10/440/40/ B.A.D.
SCRIPT=.info
BD2 quit ;quit BlitzDisk
BAD ;holds window until thru
BD2 500 nochip ;restart BD (detaches itself from window)
"Editing" with Info is sometimes tricky. For example, the [ADD] button
at the end of the tool type line only adds a line _after_ the present line;
there is no facility for making a blank line before the current line. This
really only matters if you want to ADD a line before the first line. In
this case, use the arrow gadgets (they look suspiciously like a semi-colon
here) to space up to the first line and click ADD. Type what was in the
first line in the new second line. Finally, click the up gadget once, clear
the old text with <Rt.Amiga>-X, and type in what you wanted to be first.
I have adopted the habit of always hitting the <RETURN> key to complete any
line I edit; this may not be necessary, but Info is sometimes flaky and
this seems to reduce the flakiness. Also any tool type line can be
arbitrarily long; the text will begin scrolling sideways when you reach the
end of the text window. <Shift><Lt.Arrow> and <Shift><Rt.Arrow> may be
used to jump from one end of the text to the other. There is an "unDo"
facility: typing <Rt.Amiga>-Q will restore the line to what it was before
you messed with it.
Note that the Info tool was never meant to be an editor. If your
script is longer than five lines or so, you don't want to add it in this
manner. At least I didn't, so I wrote AtatJ. AtatJ is a cli utility that
will automatically attach (or detach--sometimes you might want the script
back!) a script to a project icon. In the simplest case, when attaching
a ~info to its .info, the command would be "atatj MyScript". This would
attach the script named "MyScript" to the icon named "MyScript.info".
"MyScript" would still exist; it is not automatically deleted. AtatJ will
be discussed more fully in the detailed stuff to follow.
IconJ and AtatJ Manual Page 3
THE DETAILED STUFF--IconJ
There are four tool types of which IconJ is aware. Two of them, DELAY=
and WINDOW=, are known to IconX also. Various "switches" (all optional)
will be listed with each tool type description. These switches are case-
sensitive due to the way icon.library operates. My convention for
capitalization follows Commodore's example--most of the things IconJ
understands are required to be all capital letters. Lower case is required
only by the two "place-holder" file names, "~info" and ".info" (these are
discussed with the SCRIPT= tool). True file names, including window
specifications, may be any combination of upper and lower case.
Each tool type is described below.
DELAY=(numeric parameter)
The DELAY= tool type specifies how long, in "ticks", to wait
after the script is completed before closing the window which
IconJ opened up. A tick is 1/50 of a second; thus, "DELAY=125"
would cause a 2.5 second delay. When describing IconX, the
AmigaDOS 1.3 _Enhancer_Manual_ says that a delay of 0 causes the
window to remain open until ^C is entered from the keyboard.
This does not happen; a delay of 0 causes the window to be
closed without any delay. IconJ follows this behavior of IconX.
When the DELAY= tool is absent, delay defaults to 2 seconds.
The presence or absence of the DELAY= tool controls whether an
interactive console automatically closes or remains as a cli.
(See the discussion of the CLI switch below (with SCRIPT=).)
WINDOW=(console window specification OR output file name)
A console window is a text window like that in which the cli or
shell functions. Scripts require output to go somewhere
(normally a console, but perhaps a file or device), and
many scripts rely on a console for keyboard input. There are
several different kinds of consoles, the three main ones being
"CON:", "NEWCON:", and "RAW:". The specification for a console
includes three parts: which console, how big and where to put
the window, and the window's name. For example, the default
console specification (spec) when the WINDOW= tool is absent is:
CON:0/50/640/80/IconJ
This tells the Amiga to open a console of type CON: at the left
edge of the Workbench screen and 50 pixels down. Make the
window 640 pixels wide and 80 pixels high, and name it "IconJ".
IconJ and AtatJ Manual Page 4
Relative Window Specification
IconJ significantly extends the window specification to allow
for "relative" positions and sizes. Relative to what?--The
Workbench screen. Many US users assume that the Workbench is
always 640x200; some know they can get an interlaced Workbench
of 640x400. In Europe, however, a different video standard
is used which provides many more lines (but more flicker when
interlaced). Additionally, there are several programs that
allow for a wide latitude in setting Workbench size. This will
get even more complex when WB 1.4 and the enhanced chip
set are released. The point to this is that having absolute
literal numbers within the console spec limits its utility.
I have added two operators to the numeric parts of the console
specification, "-" and ".". The "-" operator interprets the
following number as negative and to be subtracted from the full
Workbench dimension. So the left-edge and window-width numbers
would be subtracted from the WB width, and the top-edge and
window-height numbers would be subtracted from WB height. The
"." operator interprets the following number as if it is a
fraction of the full WB dimension. If the fraction is greater
than or equal to one, then 100% of the given WB dimension is
used. The two operators may be mixed in any or all of the four
numeric fields, and some fields may be relative while others
are absolute. Nonsense specs are overridden, and the smallest
allowable size is 50 wide by 20 high. An example of a
relative console is:
CON:.25/1/-.3/-1/I'm_Relative
With a 700x480 WB screen, this would be interpreted as:
left edge = 700 * .25 = 175
top edge = 1
width = 700 - (700 * .3) = 700 - 210 = 490
height = 480 - 1 = 479
I don't know that it is useful to allow negative fractions, but
it does make sense mathematically. Besides, there was no
reason to forbid it. Note that there is a huge difference
between "/1/" and "/1./"--the second case is hundreds of times
larger than the first!
Alternative Output
IconX has an undocumented feature which allows the WINDOW= tool
to specify "prt:", in which case script output goes to the
printer; no console window is used. IconJ allows this also,
but extends the concept to allow output to any file or device
which can be opened to receive text. If for some reason the
file/device cannot be opened (eg protected disk), IconJ output
is directed to its default console window. It may sometimes be
useful to have no output at all, in which case the Amiga device
"nil:" would be specified. Whenever something other than a
console window is used, the script should not be interactive;
a CLI switch within the SCRIPT= tool will be overridden.
IconJ and AtatJ Manual Page 5
WINDOW examples:
WINDOW=con:0/50/640/80/IconJ
WINDOW=newcon:.1/10/.8/-20/Centered Window
WINDOW=prt:
WINDOW=nil:
WINDOW=pipe:pipename
WINDOW=catalogs:Jan90/latest_from_IconJ
(note that the "pipe:" and "newcon:" examples would require
that these devices be specifically mounted beforehand)
Conman notes
If you use Bill Hawes excellent shareware "con:" replacement,
conman, the power of the console window will be automatically
increased. Conman allows a set of switches to follow the
window title text. These switches allow for close boxes,
borderless windows, backdrop windows, etc. Read your conman
documentation file for a complete list. (I didn't plan for this
to happen--it just did. Ain't multitaskin' great!?) For the
specific case of a close box (or gadget), the shell within
the window must know about it. For example, the Arp Shell
ignores it, while WShell, of course, specifically listens for
it. (The advanced conman feature of placing a console on a
non-workbench screen is not allowed.)
Conman examples:
WINDOW=con:0/20/640/100/ MyScript /nc
creates borderless window with a close gadget
WINDOW=con:0/0/1./1.//nbds
creates a nameless borderless backdrop window
without any gadgets at all
SCRIPT=(script_name|.info|~info) [REXX] [CLI] [STARTUP] [VIEW]
This tool type is what gives IconJ much of its power. The
script name may be any full Amiga pathname, or ".info", or
"~info". Note that IconJ automatically sets the current
directory to that which contains the icon, so sometimes a path
specification is superfluous. One of the three "names" must be
present if SCRIPT= is specified; otherwise the first switch
encountered will be interpreted as the script name. When
there is no SCRIPT= tool, this is equivalent to:
SCRIPT=~info
The ~info argument is used when the script has the same name as
the icon file, but without the ".info" extension. This is the
normal relationship of an icon to its associated file.
The .info argument tells IconJ that all following tool types are
actually the script it is to execute. These tool types are
then extracted and put into a "real" but temporary file. This
temporary file is created in one of four places. The first is
the "T:" logical directory, which specifically exists for such
temporary scripts. The standard WB Startup-Sequence script
assigns T: to ram:t, which is a good place for it. Also good
IconJ and AtatJ Manual Page 6
would be rad:t or vd0:t for those who prefer recoverable ram
disks. If T: does not exist, the file then tries to be created
in the :t directory of the volume which contains the icon. If
this volume is protected or does not contain a :t directory,
the file then tries to get created in the directory containing
the script. And if that doesn't work, the file is arbitrarily
created at the top level of "RAM:". I saved this location for
last because it will create "RAM:" if it wasn't already there.
The user may have reason not to want a ramdisk, but the script
needs to go somewhere! If the file still can't get created,
IconJ decides that there is nothing it can do, so it terminates
cleanly.
The REXX switch informs IconJ that the script is an ARexx
script. IconJ then uses the "Rx" program to activate it.
Otherwise the "Execute" program activates AmigaDOS scripts.
The CLI switch informs IconJ that the script requires keyboard
input. The console window is made interactive in this case.
Closure of an interactive console is controlled by the DELAY=
tool. The presence of this tool causes the console to close
automatically after the specified delay period. Its absence,
however, causes an active shell or cli to remain even after the
script completes. The "endcli" command must be given to
terminate the cli (or shell). (If you use WShell and conman,
the WShell may be terminated by clicking the close gadget--other
advanced shells may also allow this.) IconJ does not control
whether a cli or full shell opens. This magic is controlled by
your system set-up. If you have WShell installed, a WShell
will open--if you have ARP installed, either an ARP Shell or
AmigaDOS shell may open--if you have some other shell
installed, it may open. The actual choice is made by either
the "c:Run" command or by a patch to the dos.library execute()
call. Don't worry if this makes little sense; I don't
understand it either. (I had expected to get a vanilla cli
(hence the switch name). I was delighted upon realization that
a full ARP Shell opened instead. Ain't multitaskin' great!?)
The STARTUP switch is used to execute the AmigaDOS script
"s:IconJ-Startup" prior to running your main ARexx or AmigaDOS
script. This allows setting up an environment for the script
which the user normally expects, such as a group of paths to
use to find programs. When a new shell or cli is started from
an existing shell, the paths known to the parent are inherited
by the child (WB 1.3 and above). However, when a task is
started from Workbench, such as IconJ, it has no paths to
inherit. The IconJ-Startup script can help correct for this
difference. Note that IconJ-Startup should not itself require
interactive input from the keyboard, but the main script to
follow may.
The VIEW switch is mainly for debugging; it lists the command
string which is passed to the AmigaDOS execute() call. You may
want to use it out of simple curiosity, to see what IconJ is
actually doing, but you will seldom need to.
IconJ and AtatJ Manual Page 7
Note that the "|" symbol is used within the tool types to separate
the various arguments and switches. Switch order makes no
difference within the SCRIPT= tool (except that the script name
or .info or ~info must immediately follow the equals sign).
Several examples follow:
SCRIPT=s:ParkDisks
SCRIPT=marquis|REXX
SCRIPT=~info|CLI
SCRIPT=.info|REXX|VIEW
SCRIPT=:jobs/weekly/back-up|CLI|STARTUP
PATHS= [OFF] [SMART] [NOQUOTES] [NOCROP] [METOO]
This is a late addition to IconJ. It is useful when you desire
to pass multiple files to your script. Without this tool type,
each file would be expanded to include its entire pathname,
which is the action of IconX. The AmigaDOS execute() command
has a length limitation of 255 bytes, so you can imagine that
if several icons were activated which were several directories
deep, 255 bytes might well be exceeded. (IconX will actually
crash the system if it receives too many icons!) Multiple
files are passed by using what Commodore calls "extended
selection". First, the main icon (which calls IconJ) is clicked
once; then one or more other icons are clicked once each while
holding down the shift key. (WB 1.4 may provide another way to
perform extended selection.) When the final icon is clicked, it
is clicked twice, activating the first icon clicked and
remembering all the others as arguments.
The OFF switch tells IconJ not to expand any filenames to their
full pathnames. This allows the maximum number of files to be
passed to your script, but your script won't be able to find
them unless they are all in the same directory as the first
icon.
The SMART switch sometimes expands filenames. It does so only
when it senses that the filename in question is not in the same
directory as the previous file. Utilities such as "cd",
"TackOn", and "BaseName" can then be used in your script to
access the files successfully. (TackOn and BaseName are part
of Arp 1.3.)
The NOQUOTES switch should only be used when you know for a fact
that none of your file names, directory names, or volume names
contain spaces. Otherwise your script will fail when it
receives such a name. Each pathname normally has quotes around
it to allow AmigaDOS to know where the argument divisions are.
NOQUOTES should not have been necessary; all Amiga programs and
tools should accept quoted pathnames to allow for spaces in
names. Unfortunately, significant Amiga applications and
utilities exist which like neither quotes nor spaces. Because
of such deficiencies, I had to institute this option.
IconJ and AtatJ Manual Page 8
The NOCROP switch is used when you have an environment that can
accept arbitrarily long commands. The WShell package includes
a patch to execute() that will allow this; there may be others
that I am not aware of. My hope is that the 255-character
command length limitation to execute() will be lifted by
Commodore when it releases WB 1.4. With NOCROP specified,
IconJ is able to pass commands longer than 65,000 characters!
The METOO switch will pass a full pathname for ~info to the
script as its first parameter. For example, if the .info file
were named "IconJ_Manual.info", and it were stored in drawer
"RAM:TextFiles", then the 1st parameter passed to the script
would be "RAM:TextFiles/IconJ_Manual". This allows for a whole
class of generic scripts to be built that can be attached to
icons of different names, and still function properly. Note
that the script will need a ".key" statement as its first line,
such as ".key myself/A". Then, any occurrence within the script
of reference to "<myself>" will receive ~info. Thus,
`type <myself>' would be replaced by
`type "RAM:TextFiles/IconJ_Manual"' for the example above.
If multiple selection is performed, the other files selected
will follow, and they will obey the SMART and OFF switches.
(METOO does obey the NOQUOTES directive, though.)
PATHS examples:
PATHS=SMART
PATHS=OFF|METOO
PATHS=NOQUOTES|NOCROP
PATHS=NOCROP|SMART|METOO
IconJ and AtatJ Manual Page 9
THE DETAILED STUFF--AtatJ
While IconJ is a Workbench-only program, AtatJ is, naturally, a
cli-only program. It has the following command description:
Usage: AtatJ ScriptFile [InfoFile] [-(r|c|s|d|dd)]
use r switch when ScriptFile is ARexx script
use c switch when ScriptFile requires keyboard input
use s switch when s:IconJ-Startup is be executed before ScriptFile
use d switch when detaching script from InfoFile
use dd switch when duplicating script from InfoFile
When the InfoFile is not specified, its root name is assumed to be the
ScriptFile's name (e.g. MyScript and MyScript.info). If it is specifed,
then the five-character ".info" extension is not necessary. Full pathnames
may be given for both ScriptFile and InfoFile.
The switch field, if present, must begin with the "-" symbol. The
default operation of AtatJ is to join the ScriptFile with the InfoFile,
leaving the ScriptFile intact. The SCRIPT= tool type will be:
SCRIPT=.info
The "r" switch will append "|REXX" to this SCRIPT= tool, the "c" switch
will append "|CLI", and the "s" switch will append "|STARTUP". The "r",
"c", and "s" switches may be used together. The "d" and "dd" switches
should not be used in conjunction with the others (although the d's will
override them). Also, both upper and lower case are allowed for any of the
switches.
The single "d" switch detaches the script and writes it to ScriptFile.
If ScriptFile already exists, you will be asked if you want it overwritten.
Any answer other than 'y' (yes) will abort the transfer. Additionally, the
SCRIPT= tool type is removed from the icon. The "dd" switch (duplicating
detach) simply makes a copy of the script from the InfoFile to the
ScriptFile. The InfoFile itself remains intact.
There are two conditions which will terminate an attachment with no
changes being saved. The first is that the ScriptFile can contain no bytes
of value 0 (ASCII <NULL>). This prevents machine code and graphic/sound
data files from being accidentally attached. The second is that there must
be at least one newline character (ASCII <LF>) every 256 bytes. This
prevents many kinds of non-script documents from being attached. AtatJ
makes no attempt to assure that the ScriptFile is a legal script. That
would be ... difficult.
At the present time, there is a possible source of confusion when AtatJ
is used. If an icon appears on the Workbench screen, Workbench has its own
private copy of that icon. Unfortunately, this copy is inaccessible to
AtatJ, and when a script is attached to or detached from a visible icon,
only the copy on disk gets altered--Workbench's copy becomes out of date.
Closing and re-opening the drawer/disk containing the icon will force
Workbench to refresh this information. Workbench release 1.4 may fix this
problem, so that the private Workbench copy will get updated at the same
time as the disk copy.
IconJ and AtatJ Manual Page 10
INSTALLATION
To install IconJ, simply copy it to your C: directory. If you plan on
using AtatJ frequently (or have lots of space on your hard drive), install
it in C: also. Otherwise, AtatJ may be stored on some accessible disk to
use as needed. If you plan on advanced use of IconJ, probably involving
interactive shells, edit the "IconJ-Startup" file for your purposes and
store it in your S: directory.
GRACIAS AMIGAS Y AMIGOS Y CP/M'ers TAMBIEN
I've been using public domain software and "freeware" for over ten
years now. Thank you to all who share their work in this manner. For a
long time, I've wanted to pay them back (forward, as Robert Heinlein would
have said), but it just never seemed to happen. With IconJ, though, I now
do so. This is not "shareware"; I do not desire donations from those who
use it. I would be happy to receive comments and suggestions, however.
A special thanks I give to my team of Beta testers. Without their
bug-finding and suggestions, IconJ and AtatJ would not be worth your using.
(Only I can be blamed if bugs/flaws still remain, however!) In
alphabetical order, this dedicated team included: David Zaroski, Jon Wolf,
Donnie Mickish, Andy Levy, Bill Hawes, Bill Cavanaugh, Dan Brookshier, and
Jim Biggs.
Sincerely,
Richard W. Franzen
1159 Sanddune Lane #107
Melbourne, FL 32935
5 February 1990
IconJ and AtatJ Manual Page 11